package com.xiaoshuidi.cloud.module.bpm.controller.admin.memo;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.bpm.controller.admin.memo.vo.BpmMemoPageVO;
import com.xiaoshuidi.cloud.module.bpm.controller.admin.memo.vo.BpmMemoVO;
import com.xiaoshuidi.cloud.module.bpm.dal.dataobject.memo.BpmMemoDO;
import com.xiaoshuidi.cloud.module.bpm.service.memo.BpmMemoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.Date;
import java.util.List;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;


@Tag(name =  "个人备忘录")
@RestController
@RequestMapping("/bpm/memo")
@Validated
public class BpmMemoController {

    @Resource
    private BpmMemoService bpmMemoService;

    @PostMapping("/create")
    @Operation(summary = "新增备忘录")
    public CommonResult<String> createMemo(@Valid @RequestBody BpmMemoVO bpmAddMemoVO) {
       CommonResult<String> result = bpmMemoService.createMemo(bpmAddMemoVO);
        return result;
    }


    @PostMapping("/update")
    @Operation(summary = "修改备忘录")
    public CommonResult<String> updateMemo(@RequestBody BpmMemoVO bpmAddMemoVO){
        CommonResult<String> result = bpmMemoService.updateMemo(bpmAddMemoVO);
        return result;
    }

    @PostMapping("/complete")
    @Operation(summary = "完成备忘录")
    public CommonResult<String> completeMemo(@RequestBody BpmMemoVO bpmAddMemoVO){
        CommonResult<String> result = bpmMemoService.completeMemo(bpmAddMemoVO);
        return result;
    }

    @PostMapping("/memoList")
    @Operation(summary = "查询备忘录列表")
    public CommonResult<List<BpmMemoDO>> getMemoList(@RequestBody BpmMemoVO bpmAddMemoVO){
        List<BpmMemoDO> list= bpmMemoService.getMemoList(bpmAddMemoVO);
        return CommonResult.success(list);
    }

    @PostMapping("/getMemo")
    @Operation(summary = "根据id查询")
    public CommonResult<BpmMemoDO> getMemoById(@RequestBody BpmMemoVO bpmAddMemoVO){
        BpmMemoDO bpmMemoDO = bpmMemoService.getMemoById(bpmAddMemoVO);
        return CommonResult.success(bpmMemoDO);
    }

    @GetMapping("/getDateList")
    public CommonResult<List<Date>> getMemoDate(){
        List<Date> list=bpmMemoService.getMemoDate();
        return CommonResult.success(list);
    }

    @PostMapping("/getMemoNum")
    public CommonResult<Integer> getMemoNum(@RequestBody BpmMemoVO bpmAddMemoVO){
        Integer num= bpmMemoService.getMemoNum(bpmAddMemoVO);
        return CommonResult.success(num);
    }

    @PostMapping("/memoPage")
    @Operation(summary = "分页查询备忘录列表")
    public CommonResult<PageResult<BpmMemoDO>> getMemoPageList(@RequestBody BpmMemoPageVO bpmMemoPageVO){
        PageResult<BpmMemoDO> pageList = bpmMemoService.getMemoPageList(bpmMemoPageVO);
        return CommonResult.success(pageList);
    }

}